package com.graduate.bean;

/**
 * 弃用
 * 预计目标:实现批量增删改查功能
 * @Createtime : 2020-01-15
 * @Creator : JingChu
 */
public class LoginProvider {
/*
    public String insert(@Param("demoList") List<Object> objectList,@Param("table") String tale){
        StringBuilder builder=new StringBuilder();
        builder.append("INSERT INTO demo(name,age)VALUES");
        String message="(''{0}'',{1})";
        int i=1;
        for (Object o : objectList) {
            String s = MessageFormat.format(message, o.getName(), o.getAge());
            builder.append(s);
            if (i==objectList.size()){break;}
            builder.append(",");
            i++;
        }
        return builder.toString();
    }

    public String delete(@Param("demoList") List<Object> objectList,@Param("table") String tale){
        StringBuilder builder=new StringBuilder();
        builder.append("DELETE FROM demo WHERE id IN (");
        int i=1;
        for (Object o : objectList) {
            builder.append(o.getId());
            if (i==objectList.size()){break;}
            builder.append(",");
            i++;
        }
        builder.append(")");
        return builder.toString();
    }

    public String find2(@Param("demoList") List<Object> objectList,@Param("table") String tale){
        StringBuilder builder=new StringBuilder();
        builder.append("SELECT * FROM demo WHERE id IN (");
        int i=1;
        for (Object o : objectList) {
            builder.append(o.getId());
            if (i==objectList.size()){break;}
            builder.append(",");
            i++;
        }
        builder.append(")");
        return builder.toString();
    }

    public String update(@Param("demoList") List<Object> objectList,@Param("table") String tale){
        StringBuilder builder=new StringBuilder();
        builder.append("INSERT INTO demo(id,name,age)VALUES");
        String message="({0},''{1}'',{2})";
        int i=1;
        for (Object o : objectList) {
            String s = MessageFormat.format(message, o.getId(), o.getName(), o.getAge());
            builder.append(s);
            if (i==objectList.size()){break;}
            builder.append(",");
            i++;
        }
        builder.append("on duplicate key update id=VALUES(id),age=values(age),name=VALUES(name)");
        return builder.toString();
    }
*/
}
